package com.zhongyu.item.consumer.service.Impl;

import com.zhongyu.comm.api.ItemTypeApi;
import com.zhongyu.comm.pojo.ItemType;
import com.zhongyu.item.consumer.service.ItemTypeService;
import com.zhongyu.item.consumer.vo.DaoHangVo;
import com.zhongyu.item.consumer.vo.ItemTypeVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service("ItemTypeService")
@Slf4j
public class ItemTypeServicelmpl implements ItemTypeService {

    @Resource
    private ItemTypeApi itemTypeApi;
    @Override
    public List<ItemTypeVo> queryItemType(ItemTypeVo itemTypeVo) {
        List<ItemType>itemTypes=itemTypeApi.findByParent(itemTypeVo.getParent());
        return itemTypes.stream().map(itemType -> {
            ItemTypeVo itemTypeVo1=new ItemTypeVo();
            BeanUtils.copyProperties(itemType,itemTypeVo1);
            return itemTypeVo1;
        }).collect(Collectors.toList());
    }
}
